VERSION 5.00
Begin VB.UserControl ShapeActivator 
   BackColor       =   &H00008000&
   ClientHeight    =   300
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   300
   FillStyle       =   0  'Solid
   FontTransparent =   0   'False
   ScaleHeight     =   300
   ScaleWidth      =   300
End
Attribute VB_Name = "ShapeActivator"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Const ALTERNATE = 1 ' ALTERNATE and WINDING are
Const WINDING = 2 ' constants for FillMode.

Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Long) As Long
Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As Any, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long

Private m_Move As Boolean
Private m_PntCursor As Point
Private m_Axis As Long

Public Event Slide(ByVal X, ByVal Y)
Public Event AddConnector()
Public Event SelectPort()

Property Let Axis(ByVal axi As Long)
    m_Axis = axi
End Property

Private Sub UserControl_MouseMove( _
    Button As Integer, _
    Shift As Integer, _
    X As Single, _
    Y As Single _
)
    If m_Move Then
        RaiseEvent Slide(X - m_PntCursor.X, Y - m_PntCursor.Y)
    End If
End Sub

Private Sub UserControl_MouseUp( _
    Button As Integer, _
    Shift As Integer, _
    X As Single, _
    Y As Single _
)
    Select Case Button
        Case vbLeftButton
            m_Move = False
        Case vbRightButton
        Case vbMiddleButton
            'RaiseEvent AddConnector
            'Set m_SelectPort = Nothing
    End Select
End Sub

Private Sub UserControl_MouseDown( _
    Button As Integer, _
    Shift As Integer, _
    X As Single, _
    Y As Single _
)
    Dim con As Connector
    Select Case Button
        Case vbLeftButton
            m_Move = True
            m_PntCursor.X = X
            m_PntCursor.Y = Y
        Case vbRightButton
            RaiseEvent SelectPort
            m_Editor.InvokeMenu inActivatorMenu
            Set m_SelectPort = Nothing
        Case vbMiddleButton
            'RaiseEvent SelectPort
            RaiseEvent AddConnector
    End Select
End Sub

Private Sub UserControl_Paint()
    Dim tri As Long, pnt(2) As Point
    'Select Case m_Axis
    '    Case axisXU
            pnt(0).X = 0
            pnt(0).Y = 0
            pnt(1).X = 0
            pnt(1).Y = Height / Screen.TwipsPerPixelY
            pnt(2).X = Width / Screen.TwipsPerPixelX
            pnt(2).Y = Height / (2 * Screen.TwipsPerPixelY)
    '    Case axisXD
    '        pnt(0).X = 0
    '        pnt(0).Y = Height / Screen.TwipsPerPixelY
    '        pnt(1).X = Width / Screen.TwipsPerPixelX
    '        pnt(1).Y = Height / Screen.TwipsPerPixelY
    '        pnt(2).X = Width / (2 * Screen.TwipsPerPixelX)
    '        pnt(2).Y = 0
    '    Case axisYU
    '        pnt(0).X = 0
    '        pnt(0).Y = 0
    '        pnt(1).X = Width / Screen.TwipsPerPixelX
    '        pnt(1).Y = 0
    '        pnt(2).X = Width / (2 * Screen.TwipsPerPixelX)
    '        pnt(2).Y = Height / Screen.TwipsPerPixelY
    '    Case axisYD
    '        pnt(0).X = Width / Screen.TwipsPerPixelX
    '        pnt(0).Y = 0
    '        pnt(1).X = Width / Screen.TwipsPerPixelX
    '        pnt(1).Y = Height / Screen.TwipsPerPixelY
    '        pnt(2).X = Width / Screen.TwipsPerPixelX
    '        pnt(2).Y = Height / (2 * Screen.TwipsPerPixelY)
    'End Select
    tri = CreatePolygonRgn(pnt(0), 3, ALTERNATE)
    SetWindowRgn hWnd, tri, True
End Sub

